# 图像缩放

import cv2
import numpy as np

# 读取图片
src = cv2.imread("src/lena.png", cv2.IMREAD_UNCHANGED)
print(src.shape)

# 图像缩放
result = cv2.resize(src, (200, 100))
print(result.shape)
# 显示图像
cv2.imshow("src", src)
cv2.imshow("result", result)
# 等待显示
cv2.waitKey(0)
cv2.destroyAllWindows()

# 原始图像像素乘以缩放系数
rows, cols = src.shape[:2]
print(rows, cols)
# 图像缩放 dsize(列,行)
result = cv2.resize(src, (int(cols * 0.6), int(rows * 1.2)))
# 显示图像
cv2.imshow("src", src)
cv2.imshow("result", result)
# 等待显示
cv2.waitKey(0)
cv2.destroyAllWindows()

# 图像缩放（(fx,fy) 缩放倍数的方法对图像进行放大或缩小）
result = cv2.resize(src, None, fx=0.3, fy=0.3)
# 显示图像
cv2.imshow("src", src)
cv2.imshow("result", result)
# 等待显示
cv2.waitKey(0)
cv2.destroyAllWindows()

